package com.hejing.Collection子接口Set;

import java.util.HashSet;
import java.util.Iterator;

/**
 * ClassName: RandomNoDuplicateTest
 * Package: com.hejing.Collection子接口Set
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-05-18 20:50
 * @Version: 1.0
 */
public class RandomNoDuplicateTest {
    public static void main(String[] args) {

        HashSet set = new HashSet();
        while(set.size() < 10 ) {
            int ranNum = (int)(Math.random()*(20 - 1 + 1) + 1);
            set.add(ranNum);
        }
        Iterator iterator = set.iterator();
        while(iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
















